package Leetcode.DayTest.Test_xiecheng_2019;

import java.util.*;
/**
 * @Author: kirito
 * @Date: 2025/4/7 10:39
 * @Description:
 * https://www.nowcoder.com/exam/test/87389781/detail?pid=16620108&examPageSource=Company&subTabName=written_page&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fcompany%3FcurrentTab%3Drecommand%26jobId%3D100%26tagIds%3D153&testclass=%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91
 */

public class findOrder {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        List<Order> orders = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int orderId = scanner.nextInt();
            int checkIn = scanner.nextInt();
            int checkOut = scanner.nextInt();
            orders.add(new Order(orderId, checkIn, checkOut));
        }

        List<Integer> result = new ArrayList<>();
        for (Order order : orders) {
            if (A >= order.checkIn && A <= order.checkOut) {
                result.add(order.orderId);
            }
        }

        if (result.isEmpty()) {
            System.out.println("null");
        } else {
            Collections.sort(result);
            for (int id : result) {
                System.out.println(id);
            }
        }
    }

    static class Order {
        int orderId;
        int checkIn;
        int checkOut;

        Order(int orderId, int checkIn, int checkOut) {
            this.orderId = orderId;
            this.checkIn = checkIn;
            this.checkOut = checkOut;
        }
    }

}
